package cn.demoncat.util.pay.yeepay.entity;

import cn.demoncat.util.pay.yeepay.constant.TradeRefundStatus;

import java.math.BigDecimal;

/**
 * 响应参数-申请退款
 *
 * @author 延晓磊
 * @since 2020年10月19日
 */
public class TradeRefundResult extends YeepayResult{

    // 订单编号（对应交易订单）
    private String orderId;
    // 退款申请号
    private String refundRequestId;
    // 易宝退款单号
    private String uniqueRefundNo;
    // 退款金额（元）
    private BigDecimal refundAmount;
    // 退款状态：TradeRefundStatus.name()
    private String status;

    /**
     * 构建结果
     *
     * @param other 请求结果
     * @return
     *
     * @author 延晓磊
     * @since 2020年10月19日
     */
    public static TradeRefundResult build(YeepayResult other){
        return build(other.check(null,null,"OPR00000"), TradeRefundResult.class);
    }

    /**
     * 查询退款状态
     *
     * @author 延晓磊
     * @since 2020年10月19日
     */
    public TradeRefundStatus status() {
        if (this.status != null) {
            return TradeRefundStatus.valueOf(this.status);
        }
        return null;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getRefundRequestId() {
        return refundRequestId;
    }

    public void setRefundRequestId(String refundRequestId) {
        this.refundRequestId = refundRequestId;
    }

    public String getUniqueRefundNo() {
        return uniqueRefundNo;
    }

    public void setUniqueRefundNo(String uniqueRefundNo) {
        this.uniqueRefundNo = uniqueRefundNo;
    }

    public BigDecimal getRefundAmount() {
        return refundAmount;
    }

    public void setRefundAmount(BigDecimal refundAmount) {
        this.refundAmount = refundAmount;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
}
